-
-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed texture clamping caused by texture coordinates being outside of (0,1) interval #188
Conversation
I can confirm this fixes the pixel artifacts, however I don't think this approach is always the best as this stretches the wallpaper to fit the size given by either the monitor or window. I believe that there could/should be a command line flag to change the behavior. On OLED screens I imagine it could be desirable to just leave the pixels outside completely black, whereas for my current personal wallpaper I would prefer cropping the sides to not stretch out the image. But to not undermine your work, this is 100% a lot better than before and the code definitely looks much cleaner and simpler to me! |
Added --clamp-strategy option, with stretch, border, repeat, clamp arguments. Can be shortend to -t and arguments to s, b, r, c. @Teddy-Kun for your case you should be able to write: Not that important, but I also had to add in WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.cpp
|
Just realized that this issue might be related to #90 , so I would add another flag option and make zoom fill another option too. For now I just made it default. Looks fine to me, but I'm not sure it really works correctly, so more thought must be put into that. So yeah, it's either zoomed to full width or to full height. |
4cebccd
to
f433218
Compare
OverviewSo I added 2 flags:
Scaling mode should work with different screens, so you could for example set stretch for one wallpaper and fill for other. You must provide Clamping mode apply to all screens, so you can't set it for each screen individually. CodeAdded new class CWallpaperState files: Added CWallpaperState as new member in CWallpaper class. CWallpaperState saves last viewport, projection, vflip and UVs values. Now if nothing have changed(viewport, projection, vflip) then old UVs coordinates are used (or more simple: UVs are cached). If any new scaling algorithm will be needed in the future, then it can be easily(I hope) added:
How Fit/Fill worksI think it's better to explain it with example with different sizes of wallpaper. Here we will only look on examples were only width is different, because the same logic applies to height. Both equal Width is smaller Width is bigger The same principles applies if width is equal for screen and wallpaper, but the height differs. Fit
Fit
MiscellaneousBoth Also added |
be65768
to
9aeb402
Compare
9aeb402
to
11666ab
Compare
@@ -1,3 +1,4 @@ | |||
#include <GL/glew.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't compile without that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made simple review, hopefully it will be useful
@@ -28,9 +28,29 @@ struct option long_options[] = { | |||
{ "noautomute", no_argument, nullptr, 'm' }, | |||
{ "no-fullscreen-pause", no_argument, nullptr, 'n' }, | |||
{ "disable-mouse", no_argument, nullptr, 'e' }, | |||
{ "scaling", required_argument, nullptr, 't' }, | |||
{ "clamping", required_argument, nullptr, 't' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both use 't' to use less letters
size_t hash = customHash(optarg); | ||
// Use a switch statement with the hash | ||
switch (hash) { | ||
// --scale options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are scale options
case customHash("default"): | ||
this->settings.render.window.scalingMode = WallpaperEngine::Render::CWallpaperState::TextureUVsScaling::DefaultUVs; | ||
break; | ||
// --clamp options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are clamp options
{ | ||
public: | ||
// Scaling modes. Defines how UVs coordinates are calculated. | ||
enum class TextureUVsScaling : uint8_t |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are scaling options
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below are specialization templates for all scaling options
} | ||
} | ||
|
||
template<> void CWallpaperState::updateTextureUVs<CWallpaperState::TextureUVsScaling::DefaultUVs>(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is copy of code that was used to calculate UVs before(in current main branch). Behavior(resulting UVs values) should be the same as old version
@@ -290,4 +349,8 @@ void CApplicationContext::printHelp (const char* route) | |||
sLog.out ("\t--set-property <name=value>\tOverrides the default value of the given property"); | |||
sLog.out ("\t--no-fullscreen-pause\tPrevents the background pausing when an app is fullscreen"); | |||
sLog.out ("\t--disable-mouse\tDisables mouse interactions"); | |||
sLog.out ("\t--scaling <mode>\t Scaling mode for wallpaper. Can be stretch, fit, fill, default. Must be used before wallpaper provided.\n\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Help entries for --scaling
and --clamping
@@ -69,6 +69,7 @@ namespace WallpaperEngine::Assets | |||
NoInterpolation = 1, | |||
ClampUVs = 2, | |||
IsGif = 4, | |||
ClampUVsBorder = 8, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Option for --clamping
@@ -322,13 +322,13 @@ namespace WallpaperEngine::Application | |||
for (const auto& it : this->m_backgrounds) | |||
context->setWallpaper ( | |||
it.first, | |||
WallpaperEngine::Render::CWallpaper::fromWallpaper (it.second->getWallpaper (), *context, *audioContext) | |||
WallpaperEngine::Render::CWallpaper::fromWallpaper (it.second->getWallpaper (), *context, *audioContext, this->m_context.settings.general.screenScalings[it.first]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use scalling
chosen for this wallpaper
); | ||
|
||
// set the default rendering wallpaper if available | ||
if (this->m_defaultBackground != nullptr) | ||
context->setDefaultWallpaper (WallpaperEngine::Render::CWallpaper::fromWallpaper ( | ||
this->m_defaultBackground->getWallpaper (), *context, *audioContext | ||
this->m_defaultBackground->getWallpaper (), *context, *audioContext, this->m_context.settings.render.window.scalingMode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use last chosen --scalling
option
{ | ||
glBindBuffer (GL_ARRAY_BUFFER, this->m_texCoordBuffer); | ||
glBufferData (GL_ARRAY_BUFFER, size, texCoords, GL_STATIC_DRAW); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't used anywhere, so I removed it. Probably should have let it stay.
The PR looks pretty good. There's slight adjustements I'd make to how scaling is calculated (mainly using templates to provide the different implementations), but I don't know when I'll have time to properly look at these, so accepting the PR as is. Thanks for your contribution and sorry for the delay in reviewing this! |
Fix for issue #173.
Short description
Video gets clamped for 2659503088 wallpaper. Problem is caused by texture coordinates being out of boundaries, resulting in clamp.
Full description
Texture UV coordinates starts from 0 and ends at 1. We will change uend and see how it will affect video 2667198601.
If we have:
we will get full size video:
And if we have:
we will get only left halve of video:
And if we try to render texture out of this boundries:
texture will be clamped to the edge (because GL_CLAMP_TO_EDGE parametr in CFBO.cpp is set):
What caused problem
Previously, ustart/uend or vstart/vend could be less than 0 or bigger than 1 (for example ustart could be -0.16 and uend could be 1.15), resulting in texture clamping on left/right or top/bottom of window or screen(though I only had top/bottom clamp). By making them equal to 0 or 1 accordingly, we make sure that OpenGL renders whole texture with glDrawArrays and don't get out of boundaries so we have no clamping.
Before:
After:
Additional concerns
It probably shouldn't affect people from issue #81, but may be it's a good idea to ask if everything works fine for them.